package com.lingyun.financialmanagement.service.pojo;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lingyun.financialmanagement.dao.mapper.ProjectMapper;
import com.lingyun.financialmanagement.dao.pojo.Project;
import com.lingyun.financialmanagement.service.CompanyService;
import com.lingyun.financialmanagement.utils.CompanyUtils;
import com.lingyun.financialmanagement.vo.CompanyCost;
import com.lingyun.financialmanagement.vo.GeneralLedger;
import com.lingyun.financialmanagement.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private ProjectMapper projectMapper;

    @Override
    public Result getCompanyCost() {

        ArrayList<GeneralLedger> generalLedgers = CompanyUtils.getCompanyCost(projectMapper);
        GeneralLedger generalLedger = generalLedgers.get(generalLedgers.size() - 1);
        CompanyCost companyCost = new CompanyCost(generalLedger.getAccountBalance(), generalLedger.getCashBalance(), generalLedger.getCompanyCredit(), generalLedger.getClientReceivables(), generalLedger.getProperty(), generalLedger.getInventoryTaxAmount(), generalLedger.getBalance());
        return Result.success(companyCost);
    }

    @Override
    public Result financialAnalysis() {
        ArrayList<GeneralLedger> companyCost = CompanyUtils.getCompanyCost(projectMapper);
        return Result.success(companyCost);
    }
}
